#coding=utf-8
__author__ = 'liubin'

from project.tools import Base
from sqlalchemy import Column, Integer, String, BigInteger, ForeignKey, Boolean, Text, Numeric
from sqlalchemy.orm import relationship, backref
from sqlalchemy.sql.expression import text
from project.tools import JsonpickleMixin
from base import BaseModel


class Category(BaseModel, Base):
    """
    种类表
    """
    __tablename__ = 'm_category'
    # 种类名
    name = Column('name', String(200), nullable=False, doc=u'名称')
    gsm = Column('gsm', Numeric, nullable=False,  default=0, server_default='0', doc=u'平方米克重')
    # 备注
    comment = Column('comment', Text, nullable=False, doc=u'备注')
    # 是否被删除
    isDeleted = Column('is_deleted', Boolean, server_default=text('FALSE'), doc=u'是否已删除')

    def __init__(self, data=None):
        """
        初始化
        :param data:
        :return:
        """
        if data:
            self.name = data.get('name')
            self.gsm = data.get('gsm')
            self.comment = data.get('comment')